<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/31 0031
 * Time: 12:04
 */

namespace app\api\model;


class User extends BaseModel
{
    public function address(){
//        没有外键user_id,要用hasOne,有外键的用belongsTo
        return $this::hasOne('UserAddress','user_id','id');
    }
    public static function getByOpenID($openid){
        $user = self::where('openid','=',$openid)
        ->find();
        return $user;
    }

}